/****************************************************************************
**  @copyright  TinKinG
**  @contract   lsnbing@126.com
**
**  @brief  get System info
**  @file   systeminfo.h
**  @author TinKinG
**  @date   2018-08-08
**
**
*****************************************************************************/
#ifndef SYSTEMINFO_H
#define SYSTEMINFO_H

#include <QString>
#include <QList>

#ifdef _WIN32
#include <limits.h>
#include <intrin.h>
typedef unsigned __int32  uint32_t;

#else
#include <cstdint>
#endif

class SystemInfo
{
    class CPUID {
        uint32_t regs[4];

    public:
        explicit CPUID(unsigned int i) {
#ifdef _WIN32
            __cpuid((int *)regs, (int)i);

#else
            asm volatile
                    ("cpuid" : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
                : "a" (i), "c" (0));
            // ECX is set to zero for CPUID function 4
#endif
        }

        const uint32_t &EAX() const {return regs[0];}
        const uint32_t &EBX() const {return regs[1];}
        const uint32_t &ECX() const {return regs[2];}
        const uint32_t &EDX() const {return regs[3];}
    };
    static QList<QPair<QString,QString> > systemInfo();
public:
    SystemInfo();

    static QString getIPAddress();
    static QString getCPUInfo();
    static QString getOSInfo();
    static QString getMACAdress();
};

#endif // SYSTEMINFO_H
